package com.xugui.learn.user.pojo.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;

@Data
@TableName("user")
@Schema(description = "用户信息")
public class User {

    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "用户ID", example = "1")
    private Long id;

    @TableField("name")
    @Schema(description = "用户名称", example = "张三")
    private String name;

    @TableField(value = "age", exist = false)  // 数据库中不存在
    @Schema(description = "用户年龄", example = "18", allowableValues = {"18", "19", "20"})
    private Integer age;

    @TableField("email")
    @Schema(description = "用户邮箱", example = "zhangsan@example.com")
    @JsonIgnore  // 忽略该字段在 JSON 序列化中的输出
    private String email;

    @TableField("create_time")
    @Schema(description = "创建时间", example = "2023-05-01 12:00:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")  // 指定时间格式和时区
    private LocalDateTime createTime;

    @TableLogic  // 单独指定逻辑删除字段
    @TableField("deleted")
    @Schema(description = "逻辑删除字段", example = "false")
    private Boolean deleted;
}